﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataProcessModule.Protocol
{
    public class UpgradeFeedback : BaseInstruction
    {
        #region param

        private int CommandReceived; //反馈	1	BYTE	0：指令接收成功 1：指令接收失败

        #endregion

        #region attributes

        public int AtCommandReceived { get { return CommandReceived; } }

        #endregion

        #region construction

        public UpgradeFeedback()
        {
            instHeadInfo.instID = 0x9116;
        }

        public UpgradeFeedback(byte[] buf)
        {

            int offset = 0;
            // 获取头信息
            GetHeadInfo(buf, ref offset);
            BodyStreamSplit(buf, ref offset);
        }

        #endregion

        #region function

        public void BodyStreamSplit(byte[] buf, ref int offset)
        {
            CommandReceived = buf[offset];
        }

        public string CombinedSqlString()
        {
            string _sql = string.Empty;
            _sql = "INSERT INTO table_upgrade_feedback (TerminalKey,UpgradeFeedback) VALUES('" +
                instHeadInfo.tdPhoneNumber + "'," + CommandReceived +
                ") ON DUPLICATE KEY UPDATE UpgradeFeedback=VALUES(UpgradeFeedback);";
            return _sql;
        }

        #endregion
    }
}
